<div class="layui-card">
    <div class="layui-card-header">
        自定字段
        {{--<i class="layui-icon layui-icon-tips add_custom ajax-popup" lay-tips="添加自定字段" >添加</i>--}}
    </div>
    <div class="layui-card-body">


            <div class="layui-row">
                <div class="layui-col-md12">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">名称</label>
                            <div class="layui-input-inline">
                                <input type="text" id="key_name" placeholder="新增键名"  autocomplete="off" class="layui-input">

                            </div>
                        </div>
                        <div class="layui-inline">
                           <label style="float: left; padding: 5px 20px 0 0 "  >或者</label>
                            <div class="layui-input-inline">
                                <select  name="add_cusome" xm-select-direction="down" xm-select="add_cusome" xm-select-search-type="dl" xm-select-search xm-select-radio="">
                                    <option value="">请选择键名</option>
                                    @foreach($listmeta as $key =>$val)
                                        <option value="{{$key}}" >{{$val}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>

                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">类型</label>
                        <div class="layui-input-block">
                            <select  id="key_type">
                                <option value="">请选择类型</option>
                                @foreach(form_type_list() as $key =>$val)
                                    <option value="{{$key}}" @if(isset($config->type) && ($key == $config->type)) selected="selected" @endif>{{$val}}</option>
                                @endforeach

                            </select>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button type="button" class="layui-btn add_custom" lay-filter="add_cusome">添加自定字段</button>
                        </div>
                    </div>




                </div>

            </div>
            <div id="custome_html"></div>

    </div>
</div>
<script id="custom_tempalte" type="text/html">

    <div class="layui-row custome-row">
        <div class="layui-col-md4">
            <div class="layui-form-item">
                <label class="layui-form-label">键名</label>
                <div class="layui-input-block">
                    <input type="text" name="custom[@{{ d.key_name }}]" value="@{{ d.key_name }}" autocomplete="off" placeholder="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"></label>

                <div class="layui-input-block">
                    <button type="button" class="layui-btn layui-btn-primary layui-btn-sm del_custom" data-id="@{{ d.key_id }}">删除</button>
                    {{--<button type="button" class="layui-btn layui-btn-sm">更新</button>--}}
                </div>
            </div>
        </div>
        <div class="layui-col-md8">
            <div class="layui-form-item">
                <label class="layui-form-label">键值</label>
                <div class="layui-input-block">
                    @{{#  if(d.key_type=='picture'){ }}


                    <button type="button"  class="layui-btn upload-image">上传图片</button>
                    <div class="layui-upload-list">

                        <img class="layui-upload-img" style="width: 90px" src="@{{ d.key_value }}" >
                        <input type="hidden"  class="custom_key_val" value="@{{ d.key_value }}">
                    </div>
                    @{{#  } else { }}
                    <textarea name="custom[@{{ d.key_name }}]" placeholder="请输入内容" class="layui-textarea custom_key_val">@{{ d.key_value }}</textarea>
                    @{{#  } }}





                </div>
            </div>
        </div>
    </div>

</script>